Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@peculiar/asn1-rsa

Package Overview
Dependencies
Maintainers
6
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peculiar/asn1-rsa

ASN.1 schema of `RSA Cryptography Specifications Version 2.2` (RFC8017)

  • 2.3.13
  • latest
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is @peculiar/asn1-rsa?

@peculiar/asn1-rsa is an npm package that provides ASN.1 schema definitions for RSA cryptographic algorithms. It is useful for encoding and decoding RSA keys and signatures in ASN.1 format, which is a standard interface for representing cryptographic data.

What are @peculiar/asn1-rsa's main functionalities?

Encoding RSA Public Key

This code demonstrates how to encode an RSA public key into ASN.1 format using the @peculiar/asn1-rsa package.

const { RSAPublicKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const publicKey = new RSAPublicKey({
  modulus: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
  publicExponent: new Uint8Array([0x01, 0x00, 0x01])
});

const asn1PublicKey = AsnConvert.serialize(publicKey);
console.log(asn1PublicKey);

Decoding RSA Public Key

This code demonstrates how to decode an ASN.1 encoded RSA public key using the @peculiar/asn1-rsa package.

const { RSAPublicKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const asn1PublicKey = new Uint8Array([/* ASN.1 encoded public key bytes */]);
const publicKey = AsnConvert.parse(asn1PublicKey, RSAPublicKey);
console.log(publicKey);

Encoding RSA Private Key

This code demonstrates how to encode an RSA private key into ASN.1 format using the @peculiar/asn1-rsa package.

const { RSAPrivateKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const privateKey = new RSAPrivateKey({
  version: 0,
  modulus: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
  publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
  privateExponent: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
  prime1: new Uint8Array([0x00, 0x01]),
  prime2: new Uint8Array([0x00, 0x01]),
  exponent1: new Uint8Array([0x00, 0x01]),
  exponent2: new Uint8Array([0x00, 0x01]),
  coefficient: new Uint8Array([0x00, 0x01])
});

const asn1PrivateKey = AsnConvert.serialize(privateKey);
console.log(asn1PrivateKey);

Decoding RSA Private Key

This code demonstrates how to decode an ASN.1 encoded RSA private key using the @peculiar/asn1-rsa package.

const { RSAPrivateKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const asn1PrivateKey = new Uint8Array([/* ASN.1 encoded private key bytes */]);
const privateKey = AsnConvert.parse(asn1PrivateKey, RSAPrivateKey);
console.log(privateKey);

Other packages similar to @peculiar/asn1-rsa

Keywords

FAQs

Package last updated on 01 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc